package com.spring.boot.mvc.web;

import com.common.core.results.SingleResult;
import com.common.redis.annotation.RedisLimit;
import com.spring.boot.mvc.service.IRedisService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "redis")
public class RedisController {

    @Resource
    private IRedisService redisService;

    @GetMapping(value = "get")
    @RedisLimit(key = "222", count = 1, time = 5000)
    public SingleResult<String> getRedisValue(@RequestParam(value = "key") String key) {
        String value = redisService.getRedisValue(key);
        return SingleResult.of(value);
    }
}